package com.jokins.admin.vue.hefeng.Service.impl;

import com.jokins.admin.vue.hefeng.Service.CityService;
import com.jokins.admin.vue.hefeng.actioncontext.GetCityListDoc;
import com.jokins.admin.vue.hefeng.actioncontext.GetWeatherListDoc;
import com.jokins.admin.vue.hefeng.param.CityParam;
import com.jokins.admin.vue.hefeng.vo.CityVo;
import com.jokins.common.actions.action.ActionContext;
import com.jokins.common.actions.util.ActionDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class CityServiceImpl implements CityService {

    /**
     * 获取城市列表
     *
     * @param param
     * @return
     */

    @Override
    public List<CityVo> getCityList(CityParam param) {
        GetCityListDoc doc = new GetCityListDoc(param);
        ActionDispatcher.execute(doc);
        return (List<CityVo>) doc.getResultValue(ActionContext.RESULT_DOC_KEY);
    }

    /**
     * 根据城市名称获取城市列表
     *
     * @param cityName
     * @return
     */
    @Override
    public List<CityVo> getWeatherList(String cityName) {
        GetWeatherListDoc doc = new GetWeatherListDoc(cityName);
        ActionDispatcher.execute(doc);
        return (List<CityVo>) doc.getResultValue(ActionContext.RESULT_DOC_KEY);
    }
}
